<?php
/**
 * Created by PhpStorm.
 * User: alei
 * Date: 11/4/2017 AD
 * Time: 16:56
 */
namespace App\Models\Mysql;

//use Illuminate\Database\Eloquent\Model;
use App\Models\Traits\BaseDBMethod;

/**
 * 图片相关模型类
 * Class pre_ct_ui
 * @package App\Models\Mysql
 */
class pre_ct_ui
{
	use BaseDBMethod;
	//数据库连接配置项，见config/database.php
	const DATABASE_CONF = 'lqyw_mysql';
	//pre_ct_ui 首页轮播图所在表
	const TABLE_NAME = 'pre_ct_ui';

	//数据库连接配置项，见config/database.php
	//如果需要用ORM，需要设置此项
//	protected $connection = self::DATABASE_CONF;
	//表名，如果需要用ORM，需要设置此项
//	protected $table = self::TABLE_NAME;

	public static function getRollPictureData(&$param = [])
	{
		return self::getConnObj()->select(
			"SELECT ct_ui.tid, ct_ui.extra1, ft.subject, fp.pid".
			" FROM pre_ct_ui AS ct_ui,pre_forum_thread AS ft, pre_forum_post AS fp ".
			" WHERE ct_ui.tid=ft.tid AND ft.tid=fp.tid AND first=1 ".
			" AND category=:category AND subcategory=:subcategory ORDER BY ct_ui.displayorder ASC",
			[
				'category' => 'portal',
				'subcategory' => 'swiper'
			]);
	}

	public static function selectXianercartoon($param)
	{
		return self::getDBobj()
			->select('pre_ct_ui.*', 'fp.pid')
			->leftJoin('pre_forum_post AS fp', 'pre_ct_ui.tid', '=', 'fp.tid')
			->where('pre_ct_ui.category', $param['category'])
			->where('pre_ct_ui.subcategory', $param['subcategory'])
			->where('fp.first', 1)
			->skip(0)->take(1)
			->get();
	}

	public static function  get_ce()
    {
        return self::getConnObj()->select(
            "SELECT  * from pre_ct_ui limit 6"
           );
    }
} //! end PreCtUi
